#include <iostream>
#include <future>
#include <chrono>
#include <thread>
using namespace std;
void Add(int num1, int num2, promise<int> &pro)
{
    cout << "int Add1(int num1, int num2)" << endl;
    this_thread::sleep_for(chrono::seconds(5));
    cout << "int Add2(int num1, int num2)" << endl;
    pro.set_value(num1 + num2);
}
int main()
{
    // 异步同时执行
    promise<int> pro;
    thread th(Add, 11, 22, ref(pro));
    cout << "----------------------1----------------------" << endl;
    future<int> fut = pro.get_future();
    this_thread::sleep_for(chrono::seconds(3));
    cout << "----------------------2----------------------" << endl;
    int ret = fut.get();
    cout << ret << endl;
    cout << "----------------------3----------------------" << endl;
    th.join();
    return 0;
}